cmake_minimum_required(VERSION 3.0)
project(lua)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/objs)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/objs)

set(CMAKE_C_FLAGS "-std=gnu99 -pedantic -Wall")
add_definitions(-DLUA_USE_LINUX -D_GNU_SOURCE -D_REENTRANT)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

set(SRC_LIST lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c 
 lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c 
 lundump.c lvm.c lzio.c strbuf.c fpconv.c 
 lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c ltablib.c 
 lstrlib.c loadlib.c linit.c lua_cjson.c lua_struct.c lua_cmsgpack.c 
 lua_bit.c
)

# static library
ADD_LIBRARY(lua_static STATIC ${SRC_LIST})
set_target_properties(lua_static PROPERTIES OUTPUT_NAME "lua")
set_target_properties(lua_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(lua_static PROPERTIES LINKER_LANGUAGE "C")
set_target_properties(lua_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${LIBRARY_OUTPUT_PATH}")